﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:api="clr-namespace:ShredTheLog.Api;assembly=ShredTheLog.Api"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    >

    <DataTemplate DataType="{x:Type vm:TextChatViewModel}">
        <DockPanel x:Name="panel" Grid.Column="0">
            <TextBlock DockPanel.Dock="Top" HorizontalAlignment="Stretch" TextAlignment="Center" Text="{Binding Path=Users.Count, StringFormat={c:LocalizedString s_ConnectedUsers}}"/>
            <tk:DataGrid ItemsSource="{Binding Users}">
                <ItemsControl.ItemContainerStyle>
                    <Style TargetType="{x:Type tk:DataGridRow}">
                        <Setter Property="ContextMenu">
                            <Setter.Value>
                                <ContextMenu c:Extensions.Items="{Binding Converter={x:Static vm:UserMenuItemsConverter.Default}}" DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}"/>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="ToolTip" Value="{StaticResource UserToolTip}"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
                <tk:DataGrid.Columns>
                    <tk:DataGridTemplateColumn Header="{x:Null}" CanUserResize="False" SortMemberPath="Gender">
                        <tk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ContentPresenter Content="{Binding Gender}" HorizontalAlignment="Center"/>
                            </DataTemplate>
                        </tk:DataGridTemplateColumn.CellTemplate>
                    </tk:DataGridTemplateColumn>
                    <tk:DataGridTextColumn Header="{c:LocalizedString s_Name}" Binding="{Binding Name}" Width="*"/>
                    <tk:DataGridTextColumn Header="{c:LocalizedString s_Country}" Binding="{Binding Path=Country, Converter={x:Static cnv:CountryConverter.Default}}" c:Extensions.Comparer="{x:Static cnv:ShortUserInfoByCountryComparer.Default}" Width="*"/>
                    <tk:DataGridTextColumn Header="{c:LocalizedString s_Age}" Binding="{Binding Age}">
                        <tk:DataGridTextColumn.ElementStyle>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="TextAlignment" Value="Right"/>
                            </Style>
                        </tk:DataGridTextColumn.ElementStyle>
                    </tk:DataGridTextColumn>
                </tk:DataGrid.Columns>
            </tk:DataGrid>
        </DockPanel>

        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsLoading}" Value="true">
                <Setter TargetName="panel" Property="Cursor" Value="Wait"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>